﻿using System;
using Loki;
using Loki.UI;
using Loki.UI.Win;
using Luna.UI.Project;

namespace Luna.UI.Win.Project
{
    /// <summary>
    /// Split by month project outcome graph.
    /// </summary>
    public partial class ProjectMonthlyCostGraphView : ViewControlBase, IView<ProjectMonthlyCostGraphViewModel>
    {
        public ProjectMonthlyCostGraphView()
        {
            InitializeComponent();
            this.BindingChanged += AccountingLevelGraphView_BindingChanged;
        }

        public new ProjectMonthlyCostGraphViewModel ViewModel
        {
            get { return (ProjectMonthlyCostGraphViewModel)base.ViewModel; }
            set { base.ViewModel = value; }
        }

        private const string PROJECT_SERIES_NAME = "Project";

        private void AccountingLevelGraphView_BindingChanged(object P_Sender, EventArgs e)
        {
            CHT_Graph.Series[PROJECT_SERIES_NAME].ArgumentDataMember = ExpressionHelper.Reflect<GraphPoint<DateTime, decimal>>.GetProperty(x => x.Argument).Name;
            CHT_Graph.Series[PROJECT_SERIES_NAME].ValueDataMembers.AddRange(ExpressionHelper.Reflect<GraphPoint<DateTime, decimal>>.GetProperty(x => x.Argument).Name);
            CHT_Graph.DataSource = ViewModel.DataSource;
        }
    }
}
